package View;

import java.io.File;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.filechooser.FileView;

public class XMLFileView extends FileView {

	@Override
	public Icon getIcon(File f) {

		String extension = getExtension(f);
		if (extension != null) {
			if (extension.equals("xml")) {
				return new ImageIcon(this.getClass().getResource(
						"/Images/export_xml.png"));
			}
		}
		return null;
	}

	public String getExtension(File f) {
		String ext = null;
		String s = f.getName();
		int i = s.lastIndexOf('.');

		if (i > 0 && i < s.length() - 1) {
			ext = s.substring(i + 1).toLowerCase();
		}
		return ext;
	}
}
